﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Toenda.Foundation {
	/// <summary>
	/// Extends the Nullable class
	/// </summary>
	public static class NullableExtensions {
		/// <summary>
		/// Get the value or a specific value
		/// </summary>
		/// <typeparam name="T"></typeparam>
		/// <param name="instance"></param>
		/// <param name="specificValue"></param>
		/// <returns></returns>
		public static T GetValueOrSpecific<T>(this Nullable<T> instance, T specificValue) where T : struct {
			if(instance.HasValue) {
				return instance.Value;
			}
			else {
				return specificValue;
			}
		}
	}
}
